package classes.view.component
{
	import com.d4p.util.MouseMove;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.FocusEvent;
	import flash.events.KeyboardEvent;
	import flash.text.TextField;
	
	public class ListObject_password extends MouseMove
	{
		private var _input:TextField;
		private var _incollect:Sprite;
		
		public function ListObject_password()
		{
			super();
			setLayOut();
			defaultSetting();
			init();
		}
		
		public function set switch_cont($param:Boolean):void
		{
			if($param){
				_incollect.visible = false;
				_input.text    = "";
				playFrame('in');
				_input.visible = true;
			}else{
				_incollect.visible = false;
				_input.text    = "";
				playFrame('out');
				_input.visible = false;
			}
			
		}
		public function set collect($param:Boolean):void
		{
			_incollect.visible = !$param;
		}
		
		public function get pass():String
		{
			return this._input.text;
		}
		
		private function setLayOut():void
		{
			this._input 		= this.getChildByName('input_txt')		as TextField;
			this._incollect		= this.getChildByName('incorrect_mc')	as Sprite;
		}
		private function defaultSetting():void
		{
			this._input.displayAsPassword = true;
			this.stop();
			this._incollect.visible = false;
		}
		private function init():void
		{
			this._input.addEventListener(FocusEvent.FOCUS_IN,	onFocusInHandler);
			this._input.addEventListener(FocusEvent.FOCUS_OUT,	onFocusOutHandler);
		}
		private function onFocusInHandler(e:FocusEvent):void
		{
			stage.addEventListener(KeyboardEvent.KEY_DOWN,	onKeyDownHandler);
		}
		private function onFocusOutHandler(e:FocusEvent):void
		{
			stage.removeEventListener(KeyboardEvent.KEY_DOWN,	onKeyDownHandler);	
		}
		private function onKeyDownHandler(e:KeyboardEvent):void
		{
			//trace(e.keyCode);
			if(e.keyCode == 13){
				dispatchEvent(new Event("enterKey_in"));
			}
		}
	}
}